<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<style type="text/css">
    span.error {
        color: red;
    }
</style>


<div id="wrapper" align="center">

    <div id="header">
        <table border="0" width="100%">
            <tr>
                <td width="30%" align="left">
                    <a id="logo" href="${pageContext.request.contextPath}"></a>
                </td>
                <td>
                <td width="30%">
                    <table id="login" align="right" border="0">
                        <tr>
                            <td align="right">
                                <c:choose>
                                    <c:when test="${sessionScope.user == null}">
                                        <form:form method="post"
                                                   action="${pageContext.request.contextPath}/login"
                                                   commandName="user">

                                            <table BORDER="0">
                                                <tr>
                                                    <td colspan="2">
                                                        <span class="error"><form:errors path="email" />
                                                        </span>
                                                    </td> 
                                                </tr>
                                                <tr alight="center">
                                                    <td alight="center"><spring:message code="label.login"/>:</td>
                                                    <td alight="center">
                                                        <form:input path="email" valign="middle" tabindex="1" />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2">
                                                        <span class="error"><form:errors path="password" />
                                                        </span>
                                                    </td>         
                                                </tr>
                                                <tr alight="center">
                                                    <td alight="center"><spring:message code="label.password"/>:</td>
                                                    <td alight="center">
                                                        <form:password 
                                                            path="password" valign="middle" tabindex="2" />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td rowspan="2" alight="center">
                                                        <input type="submit" value="<spring:message code="button.login" />" align="center" valign="middle"
                                                               tabindex="3"/>
                                                    </td>
                                                </tr>
                                            </table>
                                        </form:form>
                                    </c:when>
                                    <c:otherwise>
                                        <table style="margin-top:10px;">
                                            <tr>
                                                <td align="left">
                                                    <a href="${pageContext.request.contextPath}/personal">
                                                        <img src="${pageContext.request.contextPath}/img/test/user_pic.png"/>
                                                    </a>
                                                </td>
                                                <td align="right">
                                                    <table>
                                                        <tr>
                                                            <td>
                                                            <c:out value='${sessionScope.user.email}'/>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                <a href="${pageContext.request.contextPath}/personal"> <spring:message code="label.settings" /> </a>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                <form method="post" action="${pageContext.request.contextPath}/logout">
                                                                    <input type="submit" value=' <spring:message code="button.logout" /> ' />
                                                                </form>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </table>
                                    </c:otherwise>
                                </c:choose>

                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>


